#include <fstream>
#include <string>
#include <iostream>
#include <vector>
#include <queue>
#include <unordered_set>

namespace part1
{
    struct Position
    {
        Position(int r, int c) :
            row{r}, col{c} {}

        int row;
        int col;
    };

    bool operator == (const Position& p1, const Position p2)
    {
        return p1.row == p2.row && p1.col == p2.col;
    }

    struct PathInfo
    {
        PathInfo(int r, int c, int l) : 
            row{r}, col{c}, length{l} {}

        int row;
        int col;
        int length;
    };

    std::vector<std::string> readTrails()
    {
        std::vector<std::string> trails {};

        std::ifstream infile {"./src/day23/input.txt"};
        std::string line {};
        while (std::getline(infile, line))
            trails.emplace_back(std::move(line));
        return trails;
    }

    void searchPaths(
        const std::vector<std::string>& trails,
        Position pos,
        int length,
        std::vector<Position>& reachedPos,
        std::unordered_set<int>& targetLengths
    )
    {
        const Position target {trails.size() - 1, trails.front().size() - 2};
        // Try go util meet cross
        while (true)
        {
            // Reach target
            if (pos == target)
            {
                targetLengths.emplace(length);
                return;
            }

            char trail {trails[pos.row][pos.col]};
            switch (trail)
            {
            case '>': pos.col += 1; break;
            case '<': pos.col -= 1; break;
            case '^': pos.row -= 1; break;
            case 'v': pos.row += 1; break;
            }
        }
    }

    void solution()
    {
        std::vector<std::string> trails {readTrails()};
    }

}
